//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 Tencent.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the  Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//

#pragma once

#include "trpc/common/coroutine/task_executor.h"
#include "trpc/common/coroutine/trpc/trpc_coroutine_task.h"

namespace trpc::coroutine {

template <typename Executor = TaskExecutor<TrpcCoroutineTask>>
class TrpcTaskExcutorImp : public Executor {
 protected:
  Status ExecTasksImp() override;

 private:
  Status FiberExecTask();
  Status FiberExecTaskInNotFiberWorker();
  Status FiberExecTaskInFiberWorker();
};

template <typename Executor = TrpcTaskExcutorImp<>>
class TrpcTaskDefaultExecutor : public Executor {
 protected:
  Status ExecTasksImp() override { return Executor::ExecTasksImp(); }
};

using TrpcTaskExecutor = TrpcTaskDefaultExecutor<>;

}  // namespace trpc::coroutine
